<?php
/* --------------------------------------------------------------
   import_sql.php 2011-10-23 mb
   Gambio GmbH
   http://www.gambio.de
   Copyright (c) 2011 Gambio GmbH
   Released under the GNU General Public License (Version 2)
   [http://www.gnu.org/licenses/gpl-2.0.html]
   --------------------------------------------------------------


   based on: 
   (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
   (c) 2002-2003 osCommerce(install_3.php,v 1.6 2002/08/15); www.oscommerce.com
   (c) 2003 XT-Commerce - community made shopping http://www.xt-commerce.com ($Id: install_step3.php 899 2005-04-29 02:40:57Z hhgag $) 

   Released under the GNU General Public License 
   --------------------------------------------------------------*/

if(!empty($_GET['db']) || xtc_in_array('database', $_POST['install'])){
	$db = array();

	$db['DB_SERVER'] = trim(gm_prepare_string($_POST['DB_SERVER'], true));
	$db['DB_SERVER_USERNAME'] = trim(gm_prepare_string($_POST['DB_SERVER_USERNAME'], true));
	$db['DB_SERVER_PASSWORD'] = trim(gm_prepare_string($_POST['DB_SERVER_PASSWORD'], true));
	$db['DB_DATABASE'] = trim(gm_prepare_string($_POST['DB_DATABASE'], true));

	xtc_db_connect_installer($db['DB_SERVER'], $db['DB_SERVER_USERNAME'], $db['DB_SERVER_PASSWORD']);

	mysql_query("SET names latin1");

	$db_error = false;

	if($_GET['db'] == 'css1'){
		$sql_file = DIR_FS_CATALOG . 'gambio_installer/sql/gm_css1.sql';
	}
	elseif($_GET['db'] == 'css2'){
		$sql_file = DIR_FS_CATALOG . 'gambio_installer/sql/gm_css2.sql';
	}
	elseif($_GET['db'] == 'css3'){
		$sql_file = DIR_FS_CATALOG . 'gambio_installer/sql/gm_css3.sql';
	}
	elseif($_GET['db'] == 'css4'){
		$sql_file = DIR_FS_CATALOG . 'gambio_installer/sql/gm_css4.sql';
	}
	elseif($_GET['db'] == 'blz'){
		$sql_file = DIR_FS_CATALOG . 'gambio_installer/sql/gm_blz.sql';
	}
	elseif($_GET['db'] == 'lang'){
		$sql_file = DIR_FS_CATALOG . 'gambio_installer/sql/gm_lang.sql';
	}
	elseif($_GET['db'] == 'lang2'){
		$sql_file = DIR_FS_CATALOG . 'gambio_installer/sql/gm_lang2.sql';
	}
	elseif(xtc_in_array('database', $_POST['install'])){
		$sql_file = DIR_FS_CATALOG . 'gambio_installer/sql/gambio.sql';
	}

	xtc_db_install($db['DB_DATABASE'], $sql_file);
}

if(!$db_error)
{
	$t_output = 'success';
}
else
{
	$t_output = $db_error;
}

@mysql_close();
?>